import request from "@/utils/request";
import { curCommunity } from "@/api/common";

export function downloadFile() {
  return request({
    url: "/file/downloadFile",
    responseType: "blob",
    method: "get",
  });
}

export function importExcel(params) {
  let _currCommunity = JSON.parse(window.localStorage.getItem("curCommunity"));
  let communityId;
  if (_currCommunity) {
    communityId = _currCommunity.communityId;
  } else {
    communityId = "-1";
  }
  return request({
    url: "/file/impExcel?communityId=" + communityId,
    method: "post",
    data: params,
    curCommunity,
  });
}

export function exportOpenDoorLog(params) {
  let _currCommunity = JSON.parse(window.localStorage.getItem("curCommunity"));
  if (_currCommunity) {
    params.communityId = _currCommunity.communityId;
  } else {
    params.communityId = "-1";
  }
  return request({
    url: "/file/exportOpenDoorLog",
    responseType: "blob",
    method: "post",
    params,
  });
}
